#pragma once

#include "dsegen.h"
#include "Image.h"
#include "DsegenTypes.h"
#include "RegionObject.h"

namespace dhis
{
	inline REAL _calculateCompactness(const REAL& area, const REAL& perim)
	{
		return perim/(sqrt(area));
	}

	inline REAL _calculateFormFactor(const REAL& area, const REAL& perim)
	{
		return (perim*perim)/(FOUR_PI*area);
	}

	inline REAL _calculateAspectRatio(const REAL& l, const REAL& w)
	{
		if (l > w) { return l/w; }
		return w/l;
	}

	inline REAL _calculateShapeIndex(const REAL& area, const REAL& perim)
	{
		return perim/(4.0*sqrt(area));
	}

	inline REAL _calculateSmoothness(const REAL& perim,const REAL& boxw, const REAL& boxh)
	{
		return (perim)/(2.0*(boxw+boxh));
	}


	//------------------------------------------------------------------------------
	REAL calcRegionObjectDissimilarityCriterion(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);

	//------------------------------------------------------------------------------
	REAL calcSpectralDissimilarityCriterion(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);

	//------------------------------------------------------------------------------
	REAL calcShapeDissimilarityCriterion(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);

	//------------------------------------------------------------------------------
	// 1-Norm
	REAL  sdc1Norm(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// 2-Norm
	REAL  sdc2Norm(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Infinity Norm
	REAL  sdcInfinityNorm(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Spectral Angle Mapper
	REAL  sdcSAM(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Spectral Information Divergence
	REAL  sdcSID(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Square Root of Band Sum Mean Squared Error
	REAL  sdcSQBSMSE(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Square Root of Band Maximum Mean Squared Error
	REAL  sdcSQBMMSE(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Normalized Vector Distance
	REAL  sdcNVD(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// Entropy
	REAL  sdcEntropy(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// SAR Speckle Noise
	REAL  sdcSAR(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);
	//------------------------------------------------------------------------------
	// The Standard Deviation Sum of Band Spectral Mean Values
	REAL  sdcSDSBSMV(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para);

	
	//------------------------------------------------------------------------------
	// Compactness
	REAL  shpdcCompactness(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);
	//------------------------------------------------------------------------------
	// Form Factor
	REAL  shpdcFormFactor(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);
	//------------------------------------------------------------------------------
	// Aspect Ratio
	REAL  shpdcAspectRatio(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);
	//------------------------------------------------------------------------------
	// Shape Index
	REAL  shpdcShapeIndex(const CRegionObject* obj1,const CRegionObject* obj2,const CImageInfo* img,const CParameter* para,REAL& mergedPerim);

}


